﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.ObjectModel;

namespace AOUtils.Libraries
{
    public class FunctionCollection : KeyedCollection<string, Function>
    {
        protected override string GetKeyForItem(Function item)
        {
          if (item.Arguments.Count > 0)
              return item.Arguments[0].Value;
          return Guid.NewGuid().ToString();
        }
        protected override void InsertItem(int index, Function item)
        {
            try
            {
                base.InsertItem(index, item);
            }
            catch (ArgumentException)
            {
                //Console.WriteLine(item.Name);
            }
        }
    }
}
